import time

def bubble_sort(arr):
    n = len(arr)
    for i in range(n-1):
        for j in range(n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]
    return arr

files = ["file1.txt", "file2.txt", "file3.txt"]  

for file in files:
    start_time = time.time()  

    with open(file, 'r') as f:
        values = [int(x) for x in f.read().split()]

    sorted_values = bubble_sort(values)

    end_time = time.time()  
    sorting_time = (end_time - start_time) * 1000  

    print(f"Время сортировки для файла {file}: {sorting_time} мс")